package com.kkd.kkdapp.utils;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

/******
 * 
 * @Name 空界面处理工具类
 * 
 * @author mty
 * 
 */
public class UIEmptyHandleUtil {

	/****
	 * 
	 * 列表分页空界面处理
	 * 
	 * @param activity
	 * @param firstEntryFlag
	 * @param uiNullFlag
	 * @param rl_null
	 * @param img_null
	 * @param tv_null
	 * @param nullStr
	 * @param imgID
	 * @return
	 */
	public static Boolean uiNullDispose(Activity activity,
			boolean firstEntryFlag, boolean uiNullFlag, View rl_null,
			ImageView img_null, TextView tv_null, String nullStr, int imgID) {
		if (uiNullFlag) {
			if (firstEntryFlag) {
				rl_null.setVisibility(View.VISIBLE);
				img_null.setImageResource(imgID);
				tv_null.setText(nullStr); // "暂无消息~"
				firstEntryFlag = false;
			} else {
				if (!rl_null.isShown()) {
					showToast(activity, nullStr);
				}
			}
		} else {
			rl_null.setVisibility(View.GONE);
			firstEntryFlag = false;
		}
		return firstEntryFlag;
	}

	public static Boolean uiNullDispose(Activity activity,
			boolean firstEntryFlag, boolean uiNullFlag, View nonNull_view,
			View rl_null, ImageView img_null, TextView tv_null, String nullStr,
			int imgID) {
		if (uiNullFlag) {
			if (firstEntryFlag) {
				rl_null.setVisibility(View.VISIBLE);
				nonNull_view.setVisibility(View.GONE);
				img_null.setImageResource(imgID);
				tv_null.setText(nullStr); // "暂无消息~"
				firstEntryFlag = false;
			} else {
				if (!rl_null.isShown()) {
					showToast(activity, nullStr);
				}
			}
		} else {
			rl_null.setVisibility(View.GONE);
			nonNull_view.setVisibility(View.VISIBLE);
			firstEntryFlag = false;
		}
		return firstEntryFlag;
	}

	public static void uiNullDispose(boolean uiNullFlag, View nonEmpty_view,
			View rl_null, ImageView img_null, TextView tv_null, String nullStr,
			int imgID) {
		if (uiNullFlag) {
			nonEmpty_view.setVisibility(View.GONE);
			rl_null.setVisibility(View.VISIBLE);
			img_null.setImageResource(imgID);
			tv_null.setText(nullStr);
		} else {
			nonEmpty_view.setVisibility(View.VISIBLE);
			rl_null.setVisibility(View.GONE);
		}
	}

	public static void showToast(Activity acitivity, String hintLanguage) {
		AppUtil.makeToastForCustomer(acitivity, hintLanguage);
	}
}
